@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

/* 自定义基础样式 */
@layer base {
  html {
    font-family: 'Inter', system-ui, sans-serif;
  }
  
  body {
    @apply antialiased transition-colors duration-300;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* 滚动条样式 */
  ::-webkit-scrollbar {
    width: 6px;
  }
  
  ::-webkit-scrollbar-track {
    @apply bg-gray-100;
  }
  
  ::-webkit-scrollbar-thumb {
    @apply bg-gray-300 rounded-full;
  }
  
  ::-webkit-scrollbar-thumb:hover {
    @apply bg-gray-400;
  }
}

/* 自定义组件样式 */
@layer components {
  /* 按钮样式 */
  .btn {
    @apply inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2;
  }
  
  .btn-primary {
    @apply btn bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500;
  }
  
  .btn-secondary {
    @apply btn bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500;
  }
  
  .btn-outline {
    @apply btn border-gray-300 text-gray-700 bg-white hover:bg-gray-50 focus:ring-primary-500;
  }
  
  /* 输入框样式 */
  .input {
    @apply block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm;
  }
  
  /* 卡片样式 */
  .card {
    @apply bg-white rounded-lg shadow-sm border border-gray-200 p-6;
  }
  
  /* 文本样式 */
  .text-legal {
    @apply text-gray-800 leading-relaxed;
    line-height: 1.8;
  }
  
  /* 搜索高亮 */
  .highlight {
    @apply bg-yellow-200 px-1 rounded;
  }
  
  /* 加载动画 */
  .loading-dots {
    @apply inline-block;
  }
  
  .loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
  }
  
  @keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
  }
  
  /* AI相关样式 */
  .ai-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  
  .ai-glow {
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  }
  
  .ai-glow-hover:hover {
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
  }
  
  .ai-pulse {
    animation: ai-pulse 2s infinite;
  }
  
  @keyframes ai-pulse {
    0% {
      box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    }
    50% {
      box-shadow: 0 6px 25px rgba(102, 126, 234, 0.8);
    }
    100% {
      box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    }
  }
  
  /* 打字机效果 */
  .typewriter {
    overflow: hidden;
    border-right: 2px solid #667eea;
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
  }
  
  @keyframes typing {
    from { width: 0; }
    to { width: 100%; }
  }
  
  @keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: #667eea; }
  }
}

/* 自定义工具类 */
@layer utilities {
  /* 安全区域 */
  .safe-top {
    padding-top: env(safe-area-inset-top);
  }
  
  .safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  /* 字体大小动态调整 */
  .font-size-small {
    font-size: 0.875rem;
    line-height: 1.4;
  }
  
  .font-size-normal {
    font-size: 1rem;
    line-height: 1.6;
  }
  
  .font-size-large {
    font-size: 1.125rem;
    line-height: 1.7;
  }
  
  .font-size-xlarge {
    font-size: 1.25rem;
    line-height: 1.8;
  }
  
  /* 触摸优化 */
  .touch-target {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 文本选择 */
  .select-none {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  .select-text {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
  }
  
  /* 文本截断 */
  .line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}
